/* 
 * @since 1.0 <2015-6-5> SoChishun Added.
 */
jQuery(document).ready(function(){
    
$('#sotab-{$id}').addClass('current');
    $(window.parent.document).find('#main-body').css('padding-left', 0);
    function adjustWidthHeight() {
        var width = $(document.body).width(); //浏览器当前窗口可视区域宽度
        var w = width - $('#left-cnt').width() - 10;
        $("#right-cnt").width(w);
    }
    adjustWidthHeight();
    $(window).resize(function () {
        adjustWidthHeight();
    });
    function config_main_table() {
        $('.taskstate:contains("停止")').css('color', '#F00').parent().children('.taskname').css('color', '#F00');

        // 更改呼叫速度 2014-10-6 by sutroon
        $('#speed').change(function () {
            var val = $(this).val();
            if (!confirm('您确定要更改呼叫速度吗?')) {
                return;
            }
            var url = $(this).data('updateUrl');
            if (undefined == url) {
                alert('URL错误!');
                return;
            }
            $.get(url.replace('varspeed', val), function (data) {
                if (data.success) {
                    $.somessager.alert('提示', data.message);
                } else {
                    alert(data.message);
                }
            })
        })
        // 监视状态 2014-10-29
        $('.lnk-status').click(function () {
            var url = $(this).data('url');
            var title = $(this).attr('title');
            if (undefined == title) {
                title = '窗口';
            }
            open_dialog(url, {title: title, width: 863}, 'ifrm-strategy-status');
            return false;
        })
        $('.lnk-info').click(function () {
            $('#info-dialog').dialog({height: 180, width: 510});
            return false;
        })
        autoRefreshContent('#auto-refresh-page', 30, 10, refresh_page, false);
    }
    config_main_table();
    autoRefreshContent('#auto-refresh-page', 30, 10, refresh_page);

    // 检测余额 2014-11-24 by sutroon
    function check_blance() {
        var url = $('#blance-tip').data('url');
        $.get(url, function (data) {
            if (data == '0') {
                $('#blance-tip').text('您已欠费!').show();
            }
        })
    }
    check_blance();
    setInterval(check_blance, 300000); // 30分钟检测一次账户余额
    
})